package cn.fantasy.Iterator;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @author ET
 * @description TODO
 * @date 2023/5/13 22:10
 * @Version V1.0
 */
public class MapFor {
    public static void main(String[] args) {
        HashMap<String, String> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("a", "aa");
        objectObjectHashMap.put("b", "bb");
        objectObjectHashMap.put("c", "cc");
        objectObjectHashMap.put("d", "dd");

        // 1. 迭代器
        Iterator<Map.Entry<String, String>> iterator = objectObjectHashMap.entrySet().iterator();

        while (iterator.hasNext()) {
            Map.Entry<String, String> next = iterator.next();
//            System.out.println(next.getKey());
//            System.out.println(next.getValue());
        }

        Set<String> strings = objectObjectHashMap.keySet();
        Iterator<String> iterator1 = strings.iterator();
        while (iterator1.hasNext()) {
            String next = iterator1.next();
            objectObjectHashMap.get(next);

        }

        // ForEach EntrySet
        Set<Map.Entry<String, String>> entries = objectObjectHashMap.entrySet();
        for (Map.Entry<String, String> a:
             entries) {
        }

        objectObjectHashMap.forEach((key, value) -> {
//            System.out.println(key);
//            System.out.println(value);
        });

        objectObjectHashMap.entrySet().stream().forEach((entry) -> {
            System.out.println("...");
        });

        objectObjectHashMap.entrySet().parallelStream().forEach((entry) -> {
            System.out.println("...");
        });


    }
}
